import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../controller/little_painter_controller.dart';

/// 主页
class LittlePainterMain extends StatefulWidget {
  const LittlePainterMain({super.key});

  @override
  State<LittlePainterMain> createState() => _LittlePainterMainState();
}

class _LittlePainterMainState extends State<LittlePainterMain> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: GetBuilder<LittlePainterController>(
        builder: (controller) {
          return PageView.builder(
            itemBuilder: (BuildContext context, int index) {
              return controller.bottomNavigationPages[index];
            },
            itemCount: controller.bottomNavigationPages.length,
            controller: controller.pageController,
            physics: const NeverScrollableScrollPhysics(),
          );
        },
      ),
      bottomNavigationBar: GetBuilder<LittlePainterController>(
        builder: (controller) {
          return BottomNavigationBar(
            items: controller.bottomNavigationBarItems,
            currentIndex: controller.currentIndex,
            onTap: (flag) {
              controller.setCurrentIndex(flag);
            },
            fixedColor: Colors.blue,
            type: BottomNavigationBarType.fixed,
          );
        },
      ),
    );
  }
}
